<!DOCTYPE html>
<html>
<head>
<div th:include="base-libs :: base-libs" />
<title>我的签约患者</title>

<meta name="keywords" content="keyword1,keyword2,keyword3">
<meta name="description" content="this is my page">
<meta name="content-type" content="text/html; charset=UTF-8">

<style>
	.laydate-icon{
		width:87% !important;
		padding-left: 5px;
		line-height: 28px;
		background-color: #fff;
		height: 28px;
		border: 1px solid #B6B6B6;
		border-radius: 5px;
	}
	.spanBtn{
		font-weight: bold;
    	color: blue;
    	cursor:pointer;
	}
</style>
<!--[if IE 8.0]>
<style>
	#SHZT{
		position:relative;
		top:3px;
		line-height:30px;
	}
</style>
<![endif]-->
<script th:inline="javascript">
	var tdxxArr = [[${tdxxArr}]];
</script>
<script>
	$(function(){
		$(this).registerManagerPage();
    	initView();
    	initData();
    	$("#btnQuery").trigger("click");
    })
    
    function initData(){
	    //初始化团队下拉框
		$("#YLTDID").createOptions(tdxxArr,{textField : "TDMC" , valueField : "TDID"});
	}
    	
    function initView() {
    	//回车查询
    	enterToQuery(btnQueryHandler);
    	
		$("#qyhzTable").datagrid({
				idField : "QYXXID",
				striped : true,
				clickToSelect: true,
				fitColumns: true,
				fit:true,
				scrollbarSize:15,
				singleSelect: true,
				columns : [[
// 						{field : "xz",checkbox:true},
						{field : "XM",title : "姓名",width:40, align:'center'},
						{field : "ZJHM",title : "证件号码",width:60, align:'center',formatter:function(value){
							var reg = /.{8}$/;
							return value.replace(reg,'********');
						}},
						{field : "SJHM",title : "手机号码",width:60, align:'center'},
						{field : "JTZZ",title : "家庭住址",width:110, align:'left',formatter:function(value){
								return '<span title="'+value+'">'+value+'</span>';
							}},
						{field : "RQFLMC",title : "人群分类",width:60, align:'left',formatter:function(value){
								return '<span title="'+value+'">'+value+'</span>';
							}},
						{field : "QYSJ",title : "签约时间",width:70, align:'center'},
						{field : "TDMC",title : "签约团队",width:65, align:'center',formatter:function(value){
                            return '<span title="'+value+'">'+value+'</span>';
                        }},
						{field : "FWBMC",title : "签约服务包",width:90, align:'center',formatter:function(value){
							return '<span title="'+value+'">'+value+'</span>';
						}},
						{field : "cz",title : "操作",width:50,align:'center', formatter:function(value,row,index){
							row = JSON.stringify(row).replace(/"/g, '&quot;'); 
							var s = '<span class="spanBtn" onclick="toCkfw('+ row +')">查看服务</span>';
							var x = '<span class="spanBtn" onclick="handoutTask('+ row +')">分配服务</span>';
							return s;
						}} 
				]],
				pagination : true,
				pageList: [10, 20, 50, 100, 200],
				method : "post",
				onBeforeLoad : function(params) {
					//$("#USERID").val(parent.userInfo.USERID);
					getContainerDataByClassName('conditionBox','condition',params);//查询条件
                    formatTdid(params,"YLTDID");
				},
				onLoadSuccess: function(data){
// 					alert(JSON.stringify(data))
 				},
			});
		
		//查询开始时间设置
		var startTimeObj = {
			 elem: '#QYSJ_start',
		  	 choose: function(datas){
		  		endTimeObj.min = datas;
		  	 }
		};
		laydate(startTimeObj);
		
		//查询结束时间设置
		var endTimeObj = {
				elem: '#QYSJ_end',
			  	choose: function(datas){
			  		startTimeObj.max = datas;
			    }
		};	
		laydate(endTimeObj);
	}

	/* 双向转诊跳转服务*/
	function forwardSzxt(type){
        var row = $("#qyhzTable").datagrid("getSelected");
        if(StringUtils.isEmpty(row)){
            $.QuickAlert.alertFail({content: "请选择一条记录！"});
		}else{
            row.TYPE = type;
            $.QuickRemote.AjaxJson(contextRoot + "wdqyhz/forwardSzxt", function(result){
                if(result.state == "true"){
					location = result.URL;
                }else{
                    $.QuickAlert.alertFail({content: result["faultInfo"]});
                }
            }, row);
		}
	}

    /** 团队为空时，查询所有团队  */
    function formatTdid(params,field){
        if(StringUtils.isEmpty(params[field])){
            var tdidArr = [];
            $("#YLTDID option").each(function(){
                var value = $(this).val();
                if(!StringUtils.isEmpty(value)){
                    tdidArr.push(value);
                }
            })
            params[field] = tdidArr.join(',');
        }
    }
    
    /** 查看详细服务  */
   	function toCkfw(qyData){
   		StoreCache.setCache("qyData",qyData);
   		StoreCache.setCache("backUrl","index.html");
   		$.QuickUrlUtils.redirectUrl("ckfw.html");
   	}
    	
   	/** 查询  */
   	function btnQueryHandler(){
   		$("#qyhzTable").datagrid({"url": contextRoot + "wdqyhz/queryPage.service"});
   	}
   	
   	/** 导出 */
   	function download(){
   	    var params = {"YLTDID":$("#YLTDID").val()};
        formatTdid(params,"YLTDID");
        $("#YLTDID_down").val(params.YLTDID);
   		$("#downloadForm").submit();
   	}
   	
</script>

</head>

<body>
	<div class="easyui-layout" fit="true" border="false">
		<div region="north" style="overflow:hidden;padding:15px 0px;background:#f9f9f9" border="false">
			<form action="downloadWdqyhz.service" method="post" enctype="multipart/form-data" id="downloadForm" >
				<table class="form-table" id="conditionBox">
					<tr>
						<td class="td-text">姓名：</td>
						<td class="td-content">
							<input type="hidden" name="QYLX" value="01" class="condition"/>
							<input type="hidden" name="USERID" id="USERID" class="condition"/>
							<input name="XM" class="form-control condition"  style="width: 100%;">
						</td>
						<td class="td-text">证件号码：</td>
						<td class="td-content">
							<div style="display: inline;">
								<input name="ZJHM" class="form-control condition" style="width: 100%;" />
							</div>
						</td>
						<td class="td-text">人群分类：</td>
						<td class="td-content">
							<select name="RQFL_XMDM" cacheTable="TB_ZY_RQFL" class="form-control condition" style="width: 100%;">
								<option value="">请选择</option>
							</select>
						</td>
						<td class="td-text" style="width:170px;text-align:center">
							<button id="btnQuery" class="btn btn-info" type="button" onclick="btnQueryHandler()">查询</button>
							<button type="button" onclick="download()">导出</button>
						</td>
					</tr>
					<tr class="activeQuery">
						<td class="td-text">签约日期：</td>
						<td class="td-content">
							 <input name="QYSJ_start" id="QYSJ_start" class="laydate-icon condition" />
						</td>
						<td class="td-text">至：</td>
						<td class="td-content">
							<input name="QYSJ_end" id="QYSJ_end" class="laydate-icon condition" />
						</td>
						<td class="td-text">签约团队：</td>
						<td class="td-content">
							<select id="YLTDID" name="YLTDID" class="form-control condition" style="width: 100%;">
								<option value="">请选择</option>
							</select>
							<input id="YLTDID_down" name="YLTDID_down" type="hidden" />
						</td>
						<td class="td-text"></td>
					</tr>
				</table>
			</form>
			<div style="margin-top:10px;">
				&nbsp;&nbsp;&nbsp;&nbsp;
				<!--<button type="button" onclick="">门诊预约</button>-->
				<button type="button" onclick="forwardSzxt('mz')">门诊转诊</button>
				<button type="button" onclick="forwardSzxt('zy')">住院转诊</button>
			</div>
		</div>
		<div region="center" border="false">
			<table id="qyhzTable" border="false"></table>
		</div>
	</div>
	
</body>
</html>
